package service

import (
	"context"
	__ "mt-server/basic/proto"
	"mt-server/handler/model"
)

func (s *Server) ListOrder(_ context.Context, in *__.ListOrderReq) (*__.ListOrderResp, error) {

	var or model.Order

	order, total, _ := or.ListOrder(int(in.Page), int(in.PageSize))

	var list []*__.GetOder

	for _, val := range order {
		list = append(list, &__.GetOder{
			Amount:         float32(val.Amount),
			Address:        val.Address,
			UserId:         int64(val.UserId),
			MerchantStatus: val.MerchantStatus,
			RiderStatus:    val.RiderStatus,
		})
	}

	return &__.ListOrderResp{
		List:     list,
		Page:     in.Page,
		PageSize: in.PageSize,
		Total:    total,
	}, nil
}
